<template> 
    <Select v-model="allid" @on-change="formState" size="small">
        <Option v-for="item in semesterList" :value="item.semester_id" :key="item.semester_id">{{ item.semester_name.zh? item.semester_name.zh: item.semester_name.mn }}</Option>
    </Select>
</template>
<script>  
export default {
    components: {},
    data () {
        return {
                allid:null,
                semesterList:[],
            }
        },      
        methods: { 
            //获取学期
            semester(){
                this.$http.get('api/semester/v1/semester/semesterlists').then(val=>{ 
                    this.semesterList=val.data              
                }).catch(err => {
                    this.$Message.error('学期获取失败！');
                })
            },
            formState(val){
                this.$emit('on-formstate',val)
            }
        },
        mounted(){
            this.semester()
            this.$http.get('api/semester/v1/semester/now_semester').then(val=>{
                if(val.data[1]!=null || val.data[1]!=undefined){
                    this.allid=val.data[1].semester_id 
                    this.formState(this.allid)  
                }
            })
        },
}
</script>